//
//  AuctionRecommendCell.m
//  MyNewProject
//
//  Created by 王春辉 on 2019/12/25.
//  Copyright © 2019年 sun. All rights reserved.
//

#import "AuctionRecommendCell.h"

@interface AuctionRecommendCell()

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *desLabel;
@end
@implementation AuctionRecommendCell
@synthesize imageView = _imageView;

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor whiteColor];
        self.layer.masksToBounds = true;
        self.layer.cornerRadius = 4.0;
        [self setupContentView];
    }
    return self;
}

- (void)setupContentView {
    [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_offset(15);
        make.left.mas_offset(15);
        make.right.mas_offset(-15);
        make.width.mas_equalTo(self.imageView.mas_height);
    }];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.imageView.mas_bottom).mas_offset(10);
        make.left.right.mas_equalTo(self.desLabel);
        make.bottom.mas_equalTo(self.desLabel.mas_top).mas_offset(-10);
    }];
    [self.desLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(8);
        make.right.mas_offset(-8);
        make.bottom.mas_offset(-15);
        make.height.mas_equalTo(13);
    }];
}
- (void)layoutSubviews {
    [super layoutSubviews];
    self.imageView.layer.cornerRadius = self.imageView.height * 0.5;
}

#pragma mark -- mark
- (UIImageView *)imageView {
    if (!_imageView) {
        _imageView = [[UIImageView alloc] init];
        _imageView.contentMode = UIViewContentModeScaleAspectFit;
        _imageView.layer.masksToBounds = true;
        [self addSubview:_imageView];
    }
    return _imageView;
}
- (UILabel *)titleLabel {
    if (!_titleLabel) {
        self.titleLabel = [[UILabel alloc] init];
        _titleLabel.textColor = SKColorWithHex(0x333333);
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        _titleLabel.font = SKFONT_BOLD_SIZE(15);
        [self addSubview:_titleLabel];
    }
    return _titleLabel;
}
- (UILabel *)desLabel {
    if (!_desLabel) {
        self.desLabel = [[UILabel alloc] init];
        _desLabel.textColor = SKColorWithHex(0x888888);
        _desLabel.textAlignment = NSTextAlignmentCenter;
        _desLabel.font = SKFONT_BOLD_SIZE(12);
        [self addSubview:_desLabel];
    }
    return _desLabel;
}
#pragma mark -- mark 设置数据

- (void)setTitle:(NSString *)title {
    _title = title;
    self.titleLabel.text = title;
}

- (void)setDes:(NSString *)des {
    _des = des;
    self.desLabel.text = des;
}
/**
即将刷新数据
*/
- (void)prepareReload {
    // 清楚之前的数据
    self.hidden = true;
    self.imageView.image = [UIImage new];
    self.desLabel.text = @"";
    self.titleLabel.text = @"";
}
@end
